﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;

namespace PanasonicWarranty.Business
{
    public partial class pa_WarrantyDetailReject
    {
        public static void Insert(DBWarrantyDataContext context, pa_WarrantyWaiting objWaiting, int? userID, string description)
        {
            pa_WarrantyDetailReject objReject = new pa_WarrantyDetailReject();
            objReject.ModelCode = objWaiting.ModelCode;
            objReject.ProductCode = objWaiting.ProductCode;
            objReject.AgencyID = objWaiting.AgencyID;
            objReject.CustomerPhone = objWaiting.CustomerPhone;
            try
            {
                objReject.WarrantyPackageID = pa_WarrantyPackage.GetOne(objWaiting.WarrantyPackageCode).WarrantyPackageID;
            }
            catch { }
            objReject.CreatedDate = objWaiting.ModifiedDate ?? objWaiting.CreatedDate;
            objReject.RegisterDate = objWaiting.RegisterDate;
            objReject.ConfirmDate = DateTime.Now;
            objReject.ExpiredDate = DateTime.Now;
            objReject.UserID = userID;
            objReject.WarrantyType = objWaiting.WarrantyType;
            objReject.Description = description;
            objReject.RegisteredFrom = objWaiting.RegisteredFrom;
            objReject.RegisteredPhone = objWaiting.RegisteredPhone;
            context.pa_WarrantyDetailRejects.InsertOnSubmit(objReject);
            context.SubmitChanges();
        }
    }
}
